package com.zhang.proxy;


import javax.xml.parsers.*;

import org.w3c.dom.*;
import java.io.*;


public class XMLUtil {
    public static Object getBean() {
        try{
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
            Document document;
            document = builder.parse(new File("C:\\Users\\86176\\Desktop\\Git文件\\meal_ordering_system-master\\GoF23\\src\\main\\java\\com\\zhang\\proxy\\config.xml"));

            NodeList n1 = document.getElementsByTagName("className");

            Node classNode = n1.item(0).getFirstChild();
            String cName = classNode.getNodeValue();

            Class c  = Class.forName(cName);
            Object obj = c.newInstance();
            return obj;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
